<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of View_driver
 *
 * @author admin
 */
class view_driver extends MY_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('driver_model');
    }

    public function index() {
        $id = $this->input->get('id');
        $driver = $this->driver_model->get_driver_by_id($id);
        $this->_set_form($driver);
        $this->load->view('driver/view_driver', $this->data);
    }

    private function _set_form($driver) {
        $utility = new Config_utility();
        $this->data['lbl_prefix'] = '<h5>' . $utility->check_str($driver[0]->prefix_name) . '</h5>';
        $this->data['lbl_fname'] = '<h5>' . $utility->check_str($driver[0]->first_name) . '</h5>';
        $this->data['lbl_lname'] = '<h5>' . $utility->check_str($driver[0]->last_name) . '</h5>';
        $this->data['lbl_nname'] = '<h5>' . $utility->check_str($driver[0]->nick_name) . '</h5>';
        $this->data['lbl_citizenId'] = '<h5>' . $utility->check_str($utility->format_citizenId($driver[0]->citizen_id)) . '</h5>';
        $this->data['lbl_birthday'] = '<h5>' .
                $utility->convert_date($driver[0]->birthday, $utility->DAY) . "  " .
                $utility->month_to_string($utility->convert_date($driver[0]->birthday, $utility->MONTH)) . "  " .
                $utility->convert_date($driver[0]->birthday, $utility->YEAR) .
                '</h5>';
        $this->data['lbl_address'] = '<h5>' . $utility->check_str($driver[0]->address) . '</h5>';
        $this->data['lbl_province'] = '<h5>' . $utility->check_str($driver[0]->province_name) . '</h5>';
        $this->data['lbl_postcode'] = '<h5>' . $utility->check_str($driver[0]->postcode) . '</h5>';
        $this->data['lbl_telephone'] = '<h5>' . $utility->check_str($utility->format_telephone($driver[0]->telephone)) . '</h5>';
        $this->data['lbl_status'] = '<h5>' . $utility->check_str($driver[0]->status_name) . '</h5>';
        $img = $this->driver_model->get_driver_img_by_id($driver[0]->driver_id);
        if ($img != NULL) {
            $this->data['img_picture'] = '<img src="' . base_url() . 'uploads/drivers/' . $img[0]->file_name . '" style="width:355px" \>';
        } else {
            $this->data['img_picture'] = '<img src="' . base_url() . 'images/driver/no_image.jpg" style="width:355px"  \>';
        }
    }

}
